home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / LDB171.ARJ / FBINDER.CPP < prev    next >
C/C++ Source or Header  |  1992-05-12  |  2KB  |  111 lines

  1. /*
  2.     FBinder.cpp -- Loose Data Binder v 1.7:
  3.         container class "form."
  4.  
  5.     (C) Copyright 1992  John W. Small
  6.     All rights reserved
  7.  
  8.     PSW / Power SoftWare
  9.     P.O. Box 10072
  10.     McLean, Virginia 22102 8072 USA
  11.     (703) 759-3838
  12.  
  13.     See notes in fbinder.hpp!
  14. */
  15.  
  16.  
  17. #ifndef FBinder_HPP
  18. #include "FBinder.hpp"
  19. #endif
  20.  
  21.  
  22. int FBinder::initData(/* FBinder-declared data
  23.     member initializers */)
  24. {
  25.     // initialize any FBinder-declared data
  26.     // members here
  27.     return 1;  // success
  28. }
  29.  
  30. voiD FBinder::Dassign(voiD D, const voiD S)
  31. {
  32.     // invokes FType's overloaded operator=()
  33.     (*(FType *)D) = (*(FType *)S);
  34.     return D;
  35. }
  36.  
  37. voiD FBinder::Dnew(const voiD D)
  38. {
  39.     // invokes FType's copy initializer constructor
  40.     return  (voiD) new FType(*(FType *)D);
  41. }
  42.  
  43. void FBinder::Ddelete(voiD D)
  44. {
  45.     // invokes FType's destructor
  46.     delete (FType *) D;
  47. }
  48.  
  49. void FBinder::Dstore(ostream& os, voiD D)
  50. {
  51.     // invokes operator<<(ostream&,FType&)
  52.     os << *(FType *)D << BDRendm;
  53. }
  54.  
  55. voiD FBinder::Dload(istream& is)
  56. {
  57.     FType tmp;
  58.  
  59.     is >> tmp >> BDRnextm;
  60.     return (voiD) new FType(tmp);
  61. }
  62.  
  63. void FBinder::store(ostream& os)
  64. {
  65.     Binder::store(os);
  66. //    os << FBinder-declared data members << BDRendm;
  67. //    if (!os)
  68. //        berror("unable to store FBinder "
  69. //            "data on stream");
  70. }
  71.  
  72.  
  73. FBindeR FBinder::load(istream& is, FBindeR thiS)
  74. {
  75.     int newed;
  76.  
  77. //    is >> FBinder-declared data member initializers
  78. //        >> BDRnextm;
  79. //    if (!is)  {
  80. //        sberror("unable to load FBinder "
  81. //            "data from stream");
  82. //        return FBindeR0;
  83. //    }
  84.     if (thiS)
  85.         newed = 0;
  86.     else  {
  87.         if ((thiS = new FBinder(initVFTsOnly))
  88.             == FBindeR0)  {
  89.             sberror("unable to construct "
  90.                 "new FBinder for "
  91.                 "loading");
  92.             return FBindeR0;
  93.         }
  94.         newed = 1;
  95.     }
  96.     if (!Binder::load(is,(BindeR)thiS))  {
  97.         if (newed)
  98.             delete (voiD) thiS;
  99.         return FBindeR0;
  100.     }
  101.     if (!thiS->initData(/* FBinder-declared data
  102.         member initializers */))  {
  103.         sberror("nunable to initialize FBinder "
  104.             "from reloaded stream data");
  105.         if (newed)
  106.             delete (voiD) thiS;
  107.         return FBindeR0;
  108.     }
  109.     return thiS;
  110. }
  111.